﻿using APPFrameworkStudy.DAL;
using APPFrameworkStudy.DAL.Oracle;
using APPFrameworkStudy.DAL.SqlServer;
using APPFrameworkStudy.MySql;
using APPFrameworkStudy.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace APPFrameworkStudy.Services
{
    /// <summary>
    /// 数据访问工厂类
    /// </summary>
    public class DalFactory
    {
        private static IDataContext _idataContext;

        static DalFactory()
        {
            //在这里切换底层数据库组件，可以使用配置文件或者用微软的Unity工具进行控制反转。

            //MSSQL数据库
            //_idataContext = new SqlServerDataContext();

            //Oracle数据库
            //_idataContext = new OracleDataContext();

            //mysql数据库
            _idataContext = new MySqlDataContext();
        }

        /// <summary>
        /// 数据访问对象
        /// </summary>
        public static IDataContext DataContext
        {
            get { return _idataContext; }
        }
    }
}
